home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / progjrn / pj_6_6.arc / NDPF386.ARC / GETDAT.ASM next >
Assembly Source File  |  1988-08-28  |  3KB  |  117 lines

  1. ;
  2. ; GETTIM.ASM and GETDAT.asm
  3. ;
  4. ; Author:    M. Steven Baker
  5. ; Date:        August 27, 1988
  6. ;
  7. ; a GETTIM subroutine for NDP FORTRAN-386
  8. ; must assemble with Phar LAP 386asm
  9. ; FORTRAN calling convention with INTEGER*4 arguments
  10. ;    CALL GETTIM(ihr,imin,isec,i100)
  11. ;    CALL GETDAT(iyear,imonth,iday)
  12.  
  13. .386    ; required to generate 32-bit code/data
  14.  
  15. ; It is very important when linking to F77L-EM/32 program units that any data
  16. ; segments your assembly code uses have their class name as 'DATA' in order
  17. ; to link correctly.  In addition, you must also use the GROUP directive 
  18. ; to include the data in group DGROUP.  DS and ES are set to DGROUP by the 
  19. ; FORTRAN code, and must be set that way on return.  Your code segment must
  20. ; also be included in the group CGROUP, and include the directive:
  21. ; ASSUME DS:DGROUP, CS:CGROUP
  22.  
  23. dataseg        segment    dword
  24. dataseg        ends
  25. ;
  26. codeseg    segment dword er public use32
  27. assume    cs:codeseg, ds:dataseg
  28. ;
  29. ; The procedure names must be declared public to be addressable by
  30. ; other modules.
  31. ;
  32. public    _gettim_, _getdat_
  33.  
  34. align 4
  35.  
  36. _gettim_    proc    near
  37. ;
  38. ; Upon entry to any subroutine, NDP FORTRAN-386 has pushed addresses of
  39. ; each argument onto the stack.  In the calling program,
  40. ; 'gettim' was defined as a simple subroutine; 
  41. ; When all arguments have been dealt with, 
  42. ; NDPF-386 issues a near call to the named routine.
  43. ;
  44. ; log4 = example( int2, int4, int2a, int2a(3), dp, cmpx )
  45. ;          arg1  arg2  arg3     arg4   arg5 arg6
  46. ;
  47. ;    push    ebp        ; always do this... if EBP/ESP are used
  48. ;    mov    ebp, esp    ; and this (ebp must be preserved)
  49. ;
  50. ; The arguments are pushed right to left; thus, the first argument
  51. ; is closest to ebp.  At this point, the stack contains:
  52. ;
  53. ;    offset of argn
  54. ;         ...
  55. ;    offset of arg1 = IHR
  56. ;    return code offset  (EIP) }-- four byte address from near call
  57. ;    saved ebp    <-- ebp, esp
  58. ;
  59. ; The first argument address is now 8 bytes from ebp, referenced at [ebp+8].
  60. ; Note that the minimum argument displacement is 8 for subroutines and 12
  61. ; for functions.
  62. ;
  63. ;    CALL GETTIM(ihr,imin,isec,i100)
  64. ;
  65.     mov    ah,2ch        ;DOS Get Time function
  66.     int    21h        ;returns CH=hour,   CL=minute
  67.                 ;        DH =second DL=hundredths
  68.     mov    eax,ss:[esp+4]
  69.     mov    dword ptr [eax],0    ;zero value
  70.     mov    [eax],ch        ;set minutes
  71. ;
  72.     mov    eax,ss:[esp+8]
  73.     mov    dword ptr [eax],0    ;zero value
  74.     mov    [eax],cl        ;set minutes
  75. ;
  76.     mov    eax,ss:[esp+0ch]
  77.     mov    dword ptr [eax],0    ;zero value
  78.     mov    [eax],dh        ;set seconds
  79. ;
  80.     mov    eax,ss:[esp+10h]
  81.     mov    dword ptr [eax],0    ;zero value
  82.     mov    [eax],dl        ;set 1/100 seconds
  83. ;
  84.     ret
  85. _gettim_    endp
  86.  
  87. _getdat_    proc    near
  88. ;
  89. ;    CALL GETDAT(iyear,imonth,iday)
  90. ;
  91.     mov    ah,2ah        ;DOS Get Date function
  92.     int    21h        ;returns CX=year
  93.                 ;        DH =month  DL=day
  94.     mov    eax,ss:[esp+4]
  95.     mov    dword ptr [eax],0    ;zero value
  96.     mov    [eax],cx        ;set year
  97. ;
  98.     mov    eax,ss:[esp+8]
  99.     mov    dword ptr [eax],0    ;zero value
  100.     mov    [eax],dh        ;set month
  101. ;
  102.     mov    eax,ss:[esp+0ch]
  103.     mov    dword ptr [eax],0    ;zero value
  104.     mov    [eax],dh        ;set day
  105. ;
  106.     ret
  107. _getdat_    endp
  108.  
  109.  
  110. codeseg        ends
  111.  
  112.     end
  113. ;
  114. ; Do not put any label name or expression after the end statement!  This
  115. ; defines a program entry point, which has already been defined by the
  116. ; Fortran MAIN module.
  117.